package com.zxbit.flash.base;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public abstract class BaseFragment extends Fragment {
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootView = inflater.inflate(getContentView(), null);
        onFragmentCreated(rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        onFragmentDestoryed();
    }

    public String getStringResource(int res) {
        return getActivity().getString(res);
    }

    public void showLoadingView() {
        ((BaseActivity) getActivity()).showLoadingView();
    }

    public void dismissLoadingView() {
        ((BaseActivity) getActivity()).dismissLoadingView();
    }

    public abstract int getContentView();

    public abstract void onFragmentCreated(View rootView);

    public abstract void onFragmentDestoryed();
}
